package com.xianbeiying.app.ckgl.adapter;

import android.content.Context;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.xianbeiying.app.ckgl.R;
import com.xianbeiying.app.ckgl.widght.dashview.DashboardView;
import com.xianbeiying.app.ckgl.widght.dashview.HighlightCR;

import java.util.ArrayList;
import java.util.List;

/**
 * 圆形刻度盘数据
 */
public class CircleAdapter extends BaseAdapter{
    private Context context;
    private int [] coid={30,50,78,45,90,20};
    private int [] max={100,60,80,90,100,50};
    public CircleAdapter(Context context) {
        this.context = context;
    }
    @Override
    public int getCount() {
        return 1;
    }

    @Override
    public Object getItem(int position) {
        return getItem(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_reinfo_cicle, parent, false);
            holder = new ViewHolder();
            holder.dashboard_view_3=(DashboardView)convertView.findViewById(R.id.dashboard_view_3);
            convertView.setTag(holder);
        }else{
            holder = (ViewHolder) convertView.getTag();
        }
        List<HighlightCR> highlight2 = new ArrayList<>();
        highlight2.add(new HighlightCR(170, 50, ContextCompat.getColor(context,R.color.rinfo_lv)));
        highlight2.add(new HighlightCR(210, 140, ContextCompat.getColor(context,R.color.rinfo_lan)));
        highlight2.add(new HighlightCR(330, 50,ContextCompat.getColor(context,R.color.rinfo_h)));
        holder.dashboard_view_3.setStripeHighlightColorAndRange(highlight2);
//        holder.dashboard_view_3.setMaxValue();
        holder.dashboard_view_3.setRealTimeValue(coid[position],true,500);
        return convertView;
    }
    private class ViewHolder{
        DashboardView dashboard_view_3;
    }
}
